// 云对象教程: https://uniapp.dcloud.net.cn/uniCloud/cloud-obj
// jsdoc语法提示教程：https://ask.dcloud.net.cn/docs/#//ask.dcloud.net.cn/article/129
module.exports = {
	_before: function() { // 通用预处理器

	},
	/**
	 * method1方法描述
	 * @param {string} param1 参数1描述
	 * @returns {object} 返回值描述
	 */
	async add(params = {}) {

		let dbJQL = uniCloud.databaseForJQL({
			clientInfo: this.getClientInfo()
		})

		return await dbJQL.collection("xxm-bizhi-classify").add(params);

	},

	async list() {
		let dbJQL = uniCloud.databaseForJQL({
			clientInfo: this.getClientInfo()
		})
		return await dbJQL.collection("xxm-bizhi-classify").orderBy("sort asc").get();
	},


	async remove(ids = []) {
		let dbJQL = uniCloud.databaseForJQL({
			clientInfo: this.getClientInfo()
		})
		return await dbJQL.collection("xxm-bizhi-classify")
			.where(`_id in ${JSON.stringify(ids)}`).remove();
	},


	async item(id) {
		let dbJQL = uniCloud.databaseForJQL({
			clientInfo: this.getClientInfo()
		})
		return await dbJQL.collection("xxm-bizhi-classify").doc(id).get({
			getOne: true
		});
	},

	async update(params = {}) {

		let {
			_id,
			...data
		} = params;

		let dbJQL = uniCloud.databaseForJQL({
			clientInfo: this.getClientInfo()
		})

		return await dbJQL.collection("xxm-bizhi-classify").doc(_id).update({
			...data,
			createTime: Date.now()
		});

	}

}